home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Doors_System / LinesPerScreen / Main.C < prev    next >
C/C++ Source or Header  |  1996-10-31  |  4KB  |  198 lines

  1. /* **** HBBS Door Code****************************************************** */
  2.  
  3. /*
  4.   DoorName
  5.   ========
  6.  
  7.     what the door does
  8.  
  9.   Version
  10.   =======
  11.  
  12.     x.xx, release xx, dd/mm/yyyy
  13.  
  14.   Options
  15.   =======
  16.  
  17.     N_ND->ActiveDoor->SystemOptions
  18.     -------------------------------
  19.  
  20.  
  21.  
  22.     Command Line Arguments
  23.     ----------------------
  24.  
  25.     2  <option>
  26.  
  27.     3  ...
  28.  
  29.     4  .
  30.  
  31.   ToDo
  32.   ====
  33.  
  34.     what you still have to do
  35.  
  36.  
  37.  
  38. */
  39.  
  40. /* **** Includes *********************************************************** */
  41.  
  42. #include <exec/types.h>
  43. #include <exec/memory.h>
  44. #include <dos/dos.h>
  45. #include <clib/exec_protos.h>
  46. #include <clib/dos_protos.h>
  47. #include <clib/alib_protos.h>
  48.  
  49. #include <stdlib.h>
  50. #include <string.h>
  51. #include <stdio.h>
  52. #include <ctype.h>
  53. #include <time.h>
  54.  
  55. #include <HBBS/ANSI_Codes.h>
  56. #include <HBBS/Defines.h>
  57. #include <HBBS/Access.h>
  58. #include <HBBS/types.h>
  59. #include <HBBS/structures.h>
  60. #include <HBBS/hbbscommon_protos.h>
  61. #include <HBBS/hbbscommon_pragmas.h>
  62. #include <HBBS/Hbbsnode_protos.h>
  63. #include <HBBS/Hbbsnode_pragmas.h>
  64. #include <HBBS/release.h>
  65. char *versionstr="$VER: LinesPerScreen "RELEASE_STR;
  66.  
  67. /* **** Variables ********************************************************** */
  68.  
  69.  
  70. struct Library *HBBSCommonBase  = NULL;
  71. struct Library *HBBSNodeBase    = NULL;
  72.  
  73. struct BBSGlobalData *BBSGlobal = NULL;
  74. struct NodeData *N_ND           = NULL;
  75. int    N_NodeNum                = -1;
  76. char   outstr[1024];
  77.  
  78. long __stack=16*1024; // increse this in 4k incrments if you suffer from
  79.                       // random/suprious crashings after or during the running
  80.                       // of your door.
  81.  
  82. int    gargc;         // these are just copies of main()'s argc and argv..
  83. char   **gargv;
  84.  
  85. /* **** Functions ********************************************************** */
  86.  
  87.  
  88. #ifdef __SASC
  89. int CXBRK(void) { return(0); }
  90. int _CXBRK(void) { return(0); }
  91. void chkabort(void) {}
  92. #endif
  93.  
  94. static VOID cleanup(ULONG num)
  95. {
  96.   if (HBBSNodeBase)
  97.   {
  98.     HBBS_CleanUpDoor();
  99.     CloseLibrary (HBBSNodeBase);
  100.   }
  101.  
  102.   if (HBBSCommonBase)
  103.   {
  104.     HBBS_CleanUpCommon();
  105.     CloseLibrary (HBBSCommonBase);
  106.   }
  107.  
  108.   if (num) printf("Door Error = %d\n",num);
  109.  
  110.   exit(0);
  111. }
  112.  
  113. static VOID init(char *name)
  114. {
  115.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  116.   {
  117.     cleanup(1);
  118.   }
  119.  
  120.   if (!(HBBS_InitCommon()))
  121.   {
  122.     cleanup(2);
  123.   }
  124.  
  125.   if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
  126.   {
  127.     cleanup(3);
  128.   }
  129.  
  130.   if (!(HBBS_InitDoor(N_NodeNum,name)))
  131.   {
  132.     cleanup(4);
  133.   }
  134.   SetProgramName(name);
  135. }
  136.  
  137. /* **** DoorMain *********************************************************** */
  138.  
  139. void DoorMain( void )
  140. {
  141.   LONG loop;
  142.  
  143.   DOOR_WriteText(ANSI_RESET ANSI_CLS);
  144.  
  145.   for (loop=80;loop>1;loop--)
  146.   {
  147.     sprintf(outstr,"%ld\r\n",loop);
  148.     DOOR_WriteText(outstr);
  149.   }
  150.   DOOR_WriteText(ANSI_FG_YELLOW "Enter The Number you see at the top of your screen "ANSI_FG_BLUE": "ANSI_FG_WHITE);
  151.   strcpy(N_ND->CharsAllowed,"0123456789");
  152.   DOOR_GetLine(GL_EDIT|GL_DISPLAY,'\0',2,0,NULL);
  153.   if (N_ND->OnlineStatus==OS_ONLINE)
  154.   {
  155.     RemoveSpaces(N_ND->CurrentLine);
  156.  
  157.     if (N_ND->CurrentLine[0] && sscanf(N_ND->CurrentLine,"%ld",&loop))
  158.     {
  159.       if (loop<20) loop=20;
  160.  
  161.       if (N_ND->User.Valid)
  162.       {
  163.         N_ND->User.CallData.LinesPerScreen=loop;
  164.         N_ND->User.NormalData.LinesPerScreen=loop;
  165.       }
  166.     }
  167.     else
  168.     {
  169.       DOOR_WriteText("Not Changed!\r\n");
  170.     }
  171.   }
  172.  
  173. }
  174.  
  175. int main(int argc,char **argv)
  176. {
  177.   gargc=argc;
  178.   gargv=argv;
  179.  
  180.   if (sscanf(argv[1],"%d",&N_NodeNum)==0)
  181.   {
  182.     printf("Invalid/No Paramaters for door!\n");
  183.     exit (20);
  184.   }
  185.   init("LinesPerScreen");
  186.  
  187.   if (BBSGlobal=HBBS_GimmeBBS())
  188.   {
  189.     if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
  190.     {
  191.       DoorMain();
  192.     }
  193.   }
  194.   cleanup(0);
  195. }
  196.  
  197. /* **** End Of File ******************************************************** */
  198.